package application;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;


public class Manager_main_show extends Application {

    Stage stage;

    @Override
    public void start(Stage primaryStage) {
        try {
            if (primaryStage == null) {
                primaryStage = new Stage();
            }
            stage = primaryStage;
            BaseUtil.commonHandle(primaryStage, "Manager_main.fxml", "管理员");
            primaryStage.setOnCloseRequest(new WindowsCloseEvent(primaryStage));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        launch(args);
    }

    public void showWindow() throws Exception {
        start(stage);
    }
}

class WindowsCloseEvent implements EventHandler<WindowEvent> {

    private Stage stage;

    public WindowsCloseEvent(Stage stage) {
        this.stage = stage;
    }

    @Override
    public void handle(WindowEvent event) {
        event.consume();
        boolean dialog = BaseUtil.dialog("确认关闭?");
        if (dialog) {
            stage.close();
        }
    }
}
